package com.blrs.controller;

import java.util.List;
import java.util.Objects;
import javax.servlet.http.HttpServletResponse;

import com.blrs.domain.EnterpriseFollowRecords;
import com.blrs.service.enterprise.records.IEnterpriseFollowRecordsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;
import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 企业跟进记录Controller
 * 
 * @author yuxiang.chen
 * @date 2023-08-08
 */
@RestController
@RequestMapping("/enterprise/records")
public class EnterpriseFollowRecordsController extends BaseController
{
    @Autowired
    private IEnterpriseFollowRecordsService enterpriseFollowRecordsService;

    /**
     * 查询企业跟进记录列表
     */
    //@PreAuthorize("@ss.hasPermi('system:records:list')")
    @GetMapping("/list")
    public TableDataInfo list(EnterpriseFollowRecords enterpriseFollowRecords)
    {
        startPage();
        List<EnterpriseFollowRecords> list = enterpriseFollowRecordsService.selectEnterpriseFollowRecordsList(enterpriseFollowRecords);
        return getDataTable(list);
    }

    /**
     * 人员信息跟进记录列表查询
     * @param enterpriseFollowRecords
     * @return
     */
    @GetMapping("/listPerson")
    public TableDataInfo listPerson(EnterpriseFollowRecords enterpriseFollowRecords)
    {
        startPage();
        List<Object> list = enterpriseFollowRecordsService.selectEnterpriseFollowRecordsListPerson(enterpriseFollowRecords);
        return getDataTable(list);
    }

    /**
     * 导出企业跟进记录列表
     */
   // @PreAuthorize("@ss.hasPermi('system:records:export')")
    @Log(title = "跟进记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EnterpriseFollowRecords enterpriseFollowRecords)
    {
        List<EnterpriseFollowRecords> list = enterpriseFollowRecordsService.selectEnterpriseFollowRecordsList(enterpriseFollowRecords);
        ExcelUtil<EnterpriseFollowRecords> util = new ExcelUtil<EnterpriseFollowRecords>(EnterpriseFollowRecords.class);
        util.exportExcel(response, list, "企业跟进记录数据");
    }

    /**
     * 获取企业跟进记录详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:records:query')")
    @GetMapping(value = "/{recordsId}")
    public AjaxResult getInfo(@PathVariable("recordsId") String recordsId)
    {
        return success(enterpriseFollowRecordsService.selectEnterpriseFollowRecordsByRecordsId(recordsId));
    }

    /**
     * 新增企业跟进记录
     */
    //@PreAuthorize("@ss.hasPermi('system:records:add')")
    @Log(title = "跟进记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EnterpriseFollowRecords enterpriseFollowRecords)
    {
        return toAjax(enterpriseFollowRecordsService.insertEnterpriseFollowRecords(enterpriseFollowRecords));
    }

    /**
     * 修改企业跟进记录
     */
    //@PreAuthorize("@ss.hasPermi('system:records:edit')")
    @Log(title = "跟进记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EnterpriseFollowRecords enterpriseFollowRecords)
    {
        return toAjax(enterpriseFollowRecordsService.updateEnterpriseFollowRecords(enterpriseFollowRecords));
    }

    /**
     * 删除企业跟进记录
     */
   // @PreAuthorize("@ss.hasPermi('system:records:remove')")
    @Log(title = "跟进记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordsIds}")
    public AjaxResult remove(@PathVariable String[] recordsIds)
    {
        return toAjax(enterpriseFollowRecordsService.deleteEnterpriseFollowRecordsByRecordsIds(recordsIds));
    }
}
